﻿using System;
using System.Collections.Generic;
using System.Text;
using MDAControlsFramework;
using Microsoft.WindowsMobile.PocketOutlook;

namespace MDACalendar {
	/// <summary>
	/// zobrazeni udalosti v seznamu
	/// </summary>
	public class ControlDayListAppointment: MDAContainer {
		private Appointment _appointment;

		public Appointment Appointment {
			get {
				return _appointment;
			}
			set {
				_appointment = value;
				SetData();
			}
		}

		public override void Initialize() {
			base.Initialize();
		}

		/// <summary>
		/// Nastaví všechny hodnoty podle zadané události
		/// </summary>
		public void SetData() {
			for (int i = 0; i < _controls.Count; i++) {
				ControlAppointmentData control = _controls[i] as ControlAppointmentData;
				switch (control.Source) {
					case "subject":
						control.Content.Text = _appointment.Subject;
						break;
					case "body":
						control.Content.Text = _appointment.Body;
						break;
					case "categories":
						control.Content.Text = _appointment.Categories;
						break;
					case "location":
						control.Content.Text = _appointment.Location;
						break;
					case "datetime":
						control.Content.Text = Settings.FormatDateTime(_appointment);
						break;
				}
				control.Invalidate();
			}
		}
	}
}
